package com.javaEE.gamepigeon.service.impl;

import com.javaEE.gamepigeon.dao.ExperienceDao;
import com.javaEE.gamepigeon.entity.Experience;
import com.javaEE.gamepigeon.service.ExperienceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;


@Service
public class ExperienceServiceImpl implements ExperienceService {

    @Autowired
    ExperienceDao experienceDao;

    @Override
    public boolean addExperience(Integer userId, Integer comId, String commentDetail) {
        String date = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now());
        if(experienceDao.addExperience(userId,comId,commentDetail,date)==1){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean deleteExperience(Integer commentId) {
        if(experienceDao.deleteExperience(commentId)==1){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public List<Experience> queryExperience(Integer comId) {
        return experienceDao.queryExperience(comId);
    }
}
